package com.fr.web.platform.module;

import com.fr.base.FCloneable;
import com.fr.base.XMLFileManager;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class ModuleManager extends XMLFileManager
  implements Serializable, FCloneable
{
  private static final String XML_TAG = "ModuleManager";
  private List moduleList = new ArrayList();

  public String fileName()
  {
    return "platform.xml";
  }

  public Module getModule(int paramInt)
  {
    if ((paramInt < 0) || (paramInt >= this.moduleList.size()))
      return null;
    return ((Module)this.moduleList.get(paramInt));
  }

  public void addModule(Module paramModule)
  {
    this.moduleList.add(paramModule);
  }

  public int getModuleCount()
  {
    return this.moduleList.size();
  }

  public void clearModules()
  {
    this.moduleList.clear();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isAttr())
      clearModules();
    if (paramXMLableReader.isChildNode())
    {
      String str = paramXMLableReader.getTagName();
      if (str.equals("Module"))
      {
        Module localModule = new Module();
        paramXMLableReader.readXMLObject(localModule);
        addModule(localModule);
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    int i;
    paramXMLPrintWriter.startTAG("ModuleManager");
    if (this.moduleList.size() > 0)
      for (i = 0; i < this.moduleList.size(); ++i)
        ((Module)this.moduleList.get(i)).writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return clone();
  }

  public void readFromDB()
  {
  }

  public void writeToDB()
  {
  }
}